#ifndef ____SSBASEL__SSBASE__BASE_STL__H__
#define ____SSBASEL__SSBASE__BASE_STL__H__
/*!
* \file base_stl.h
* \brief
* 
*
* 
* \author patdz@qq.com
* \version 1.0
* \date 2014/05/26
*/

#include "base.h"

#include <cmath>
#pragma warning(push)
#pragma warning(disable : 4995)
#include <string>
#include <vector>
#include <map>
#pragma warning(pop)
#include <sstream>
#include <algorithm>
#include <queue>
#include <list>

_SSL_BEGIN
_SSBASEL_BEGIN


#ifdef _UNICODE
	typedef std::wstring tstring;
typedef std::wostringstream tostringstream;
#else
	typedef std::string tstring;
typedef std::ostringstream tostringstream;
#endif

#define tstrings std::vector<tstring>

//
template<class T>
class stl_singleton
{
public:
	static T* GetInstance()
	{
		if(_instance == NULL)
		{
			if(!enable_recreate_ && deleted_)
			{
				SS_ASSERT_HERE;
				return NULL;
			}
			_instance = new T;
		}
		return _instance;
	}

	static void DeleteInstance()
	{
		delete _instance;
		_instance = NULL;
		deleted_ = true;
	}

private:
	stl_singleton() {}
	~stl_singleton() {}
	stl_singleton(const stl_singleton &) {}
	stl_singleton & operator= (const stl_singleton &){}

protected:
	static T *_instance;
	static bool deleted_;
	static bool enable_recreate_;
};

template<class T>
T * stl_singleton<T>::_instance = NULL;

template<class T>
bool stl_singleton<T>::deleted_ = false;

template<class T>
bool stl_singleton<T>::enable_recreate_ = false;

_SSBASEL_END
_SSL_END


#endif
